<?php $this->pageTitle = 'Dashboard'; ?>
<?php Yii::app()->clientScript->registerScriptFile('/js/jquery.cookie/jquery.cookie.js'); ?>
<?php Yii::app()->clientScript->registerScriptFile('/js/fancybox/jquery.fancybox-1.3.4.js'); ?>
<?php Yii::app()->clientScript->registerCssFile('/js/fancybox/jquery.fancybox-1.3.4.css'); ?>

<div class="flat_area">
    <div class="grid_16 content_header clearfix">
        <h1 class="float-left">Dashboard</h1>
    </div>
    <div class="grid_16 relative">
        <div id="ps-dashboard-sidebar" class="ps-sidebar">
        </div>
        <div id="ps-dashboard-ct" class="ps-container-right">
            <div id="ps-dashboard-propertycases" class="box">
                <h2 class="box_head grad_colour with-icon"><img width="16" height="16" src="/images/icons/fugue/folder.png" />Recent Cases</h2>
                <?php
                $this->widget('zii.widgets.grid.CGridView', array(
                    'id' => 'dashboard-property-case-grid',
                    'dataProvider' => $propertyCase->searchDashboard(),
                    'template' => '{items}',
                    'emptyText' => $emptyText,
                    'htmlOptions' => array(
                        'class' => 'grid-view grey'
                    ),
                    'columns' => array(
                        array(
                            'header' => 'Address',
                            'name' => 'property_name',
                            'type' => 'raw',
                            'value' => 'CHtml::link($data->property->prop_address_1, array("case/update", "id" => $data->id));',
                            'htmlOptions' => array('class' => 'property-column'),
                        ),
                        array(
                            'header' => 'Exp. Date',
                            'name' => 'valid_date_end',
                            'value' => '(empty($data->valid_date_end) ? "-" : date("j M Y", strtotime($data->valid_date_end)))',
                            'filter' => false,
                            'htmlOptions' => array('class' => 'date-column'),
                        ),
                        array(
                            'header' => 'Ex',
                            'name' => 'is_exclusive',
                            'value' => '($data->is_exclusive == null ? "-" : ($data->is_exclusive ? "Ex" : "Non-Ex"))',
                            'filter' => array(
                                0 => 'Non-exclusive',
                                1 => 'Exclusive',
                            ),
                            'htmlOptions' => array('class' => 'exc-column'),
                        ),
                        array(
                            'header' => 'Case Type',
                            'name' => 'type',
                            'value' => '$data->getCaseTypeAbbreviated()',
                            'filter' => PropertyCase::getCaseTypes(),
                            'htmlOptions' => array('class' => 'type-column'),
                        ),
                        array(
                            'header' => 'Primary Contact',
                            'name' => 'primaryContactName',
                            'class' => 'CDataColumn',
                            'type' => 'raw',
                            'value' => '$data->getPrimaryContact()->name',
                            'htmlOptions' => array('class' => 'client-column'),
                        ),
                    ),
                ));
                ?>
            </div>
            <div id="ps-dashboard-leads" class="box">
                <h2 class="box_head grad_colour with-icon"><img width="16" height="16" src="/images/icons/fugue/money-coin.png" />Agency Performance</h2>
                <?php
                $this->widget('common.lib.highcharts.HighchartsWidget', array(
                    'options' => array(
                        'title' => array('text' => 'Agency Performance'),
                        'exporting' => array(
                            'enabled' => false
                        ),
                        'chart' => array(
                            'defaultSeriesType' => 'column'
                        ),
                        'xAxis' => array(
                            'categories' => $chartCategories
                        ),
                        'yAxis' => array(
                            'title' => array('text' => 'Amount')
                        ),
                        'series' => $chartData,
                        'plotOptions' => array(
                            'column' => array(
                                'stacking' => 'normal',
                            )
                        ),
                    )
                ));
                ?>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var welcomePopupEnabled = <?php echo ($welcomePopupEnabled ? "true" : "false"); ?>;
    var showWhatsNew = <?php echo ($showWhatsNew ? "true" : "false"); ?>;
</script>